/*
 * @Author: zhangzhengzhe
 * @Date: 2019-09-02 15:50:51
 * @LastEditors: zhangzhengzhe
 * @LastEditTime: 2019-09-03 11:43:14
 */
const Koa = require('koa')
const bodyParser = require('koa-body')
const cors = require('koa2-cors')
const xmlParser = require('koa-xml-body')
const config = require('./../config/config')
const userRouter = require('./router/index').routes()

const app = new Koa()

/* 处理formdata获取及文件上传处理 */
app.use(bodyParser(config.corsBodyParser))

/* 处理报文中间件 */
app.use(xmlParser())

/* 解决跨域 */
app.use(cors(config.corsOptions))
/**  注册路由 */
app.use(userRouter)


app.listen(config.port, () => {
  console.log(`----------------------------------service start-------------------------------\n
              service started, the ports is ${config.port}
----------------------------------service end-----------------------------------`)
})